

package view.server;
import model.User;
import model.Server;


public class PlayerPane extends javax.swing.JPanel {

    private User u;
    private Server sv;
    /** Creates new form PlayerPane */
    public PlayerPane(User u, Server sv) {
        initComponents();
        this.u = u;
        this.sv = sv;
        lblNome.setText(u.getName());
    }
    
    public User getUserName(){
        return u;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        popOpt = new javax.swing.JPopupMenu();
        optSee = new javax.swing.JMenuItem();
        optKick = new javax.swing.JMenuItem();
        optWatch = new javax.swing.JMenuItem();
        lblNome = new javax.swing.JLabel();
        lblLevel = new javax.swing.JLabel();
        lblLocation = new javax.swing.JLabel();

        popOpt.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        optSee.setText("See");
        optSee.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                optSeeActionPerformed(evt);
            }
        });
        popOpt.add(optSee);

        optKick.setText("Kick");
        optKick.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                kickOpt(evt);
            }
        });
        popOpt.add(optKick);

        optWatch.setText("Watch");
        popOpt.add(optWatch);

        setBackground(new java.awt.Color(51, 102, 255));
        setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        setComponentPopupMenu(popOpt);

        lblNome.setFont(new java.awt.Font("Verdana", 1, 12));
        lblNome.setText("PlayerName");

        lblLevel.setFont(new java.awt.Font("Tahoma", 1, 8));
        lblLevel.setText("Level X Classe Y");

        lblLocation.setFont(new java.awt.Font("Tahoma", 1, 11));
        lblLocation.setText("Location");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblNome)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(lblLocation))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(lblLevel)))
                .addContainerGap(114, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(lblNome, javax.swing.GroupLayout.PREFERRED_SIZE, 13, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblLocation)
                .addGap(3, 3, 3)
                .addComponent(lblLevel)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void kickOpt(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_kickOpt
        sv.kickPlayer(getUserName().getName());
    }//GEN-LAST:event_kickOpt

    private void optSeeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_optSeeActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_optSeeActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel lblLevel;
    private javax.swing.JLabel lblLocation;
    private javax.swing.JLabel lblNome;
    private javax.swing.JMenuItem optKick;
    private javax.swing.JMenuItem optSee;
    private javax.swing.JMenuItem optWatch;
    private javax.swing.JPopupMenu popOpt;
    // End of variables declaration//GEN-END:variables
}